from marshmallow import Schema
from flask_restplus import Namespace, fields


class CarSchemas(object):
    def __init__(self, namespace):
        self.namespace = namespace

    def car_body(self):
        return self.namespace.model(
            "car_list_query",
            {
                "id": fields.Integer(),
                "create_time": fields.DateTime(),
                "car_num": fields.String(),
                "asset_code": fields.String(),
                "vin_num": fields.String(),
            },
        )

    def car_data(self):
        return self.namespace.model(
            "car_data",
            {"total": fields.Integer(), "data": fields.List(fields.Nested(self.car_body()))},
        )

    def car_list_query(self):
        return {
            "page": "页数",
            "per_page": "页总量",
            "create_time": "时间",
            "car_num": "车号",
            "asset_code": "资产编码",
            "vin_num": "VIN码",
        }

    def car_create_query(self):
        return self.namespace.model(
            "car_create_query",
            {
                "create_time": fields.DateTime(),
                "car_num": fields.String(),
                "asset_code": fields.String(),
                "vin_num": fields.String(),
            },
        )

    def car_id(self):
        return self.namespace.model("car_id", {"id": fields.Integer()})
